package com.lovo.common.config;

import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableRabbit
public class DeadLetterMQConfig {
    @Bean
    public Exchange deadLetterExchange(){
        // 配置死信队列的交换机
        return ExchangeBuilder.directExchange("dead.letter.exchange").durable(true).build();
    }
    @Bean
    public Queue deadLetterQueue(){
        // 配置死信队列
        return new Queue("dead.letter.queue",true);
    }
    @Bean
    public Queue deadLetterPayQueue(){
        // 配置支付的死信队列
        return new Queue("dead.letter.pay.queue",true);
    }
    @Bean
    public Binding deadLetterExchangeQueueBinding(){
        return BindingBuilder.bind(deadLetterQueue()).to(deadLetterExchange()).with("dead.letter.rk").noargs();
    }
    @Bean
    public Binding deadLetterExchangePayQueueBinding(){
        return BindingBuilder.bind(deadLetterPayQueue()).to(deadLetterExchange()).with("dead.letter.pay.rk").noargs();
    }
}
